1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to encoding an image, and decoding an image, and more particularly, to encoding an image which has an optimal bit rate by performing optimal entropy coding, and decoding the image.
2. Description of the Related Art
Image compression standards include entropy coding. Hereinafter, the entropy encoding of the related art H.264 standard will be described with reference to FIG. 1.
FIG. 1 is a flowchart illustrating entropy encoding. The entropy encoding 100 of the related art H.264 standard comprises three steps; binarization 110, context modeling 120, and binary arithmetic coding 130.
In the binarization 110, an absolute value of a quantized discrete cosine transform DCT coefficient is converted into binary bit stream which consists of 0 and/or 1.
In the context modeling 120, in order to encode information related to a macroblock which is called syntax, context indexes, that is, syntax and binary values, are received.
In the binary arithmetic coding 130, a probability section is repeatedly divided according to a probability of individual symbols. A bit stream, which is generated by entropy coding and the binary arithmetic coding, is output.
FIG. 2 shows procedures of binarization according to a magnitude coding scheme.
A quantized DCT coefficient 200 includes a coefficient code 210 and a coefficient absolute value 220. A unary code of context-based adaptive arithmetic coding (CABAC) consists of either “1” bits or “0” bits. A truncated unary code is larger than 0 or smaller than a threshold, and is defined only by the same quantized DCT coefficient. A quantized DCT coefficient which is smaller than a threshold is represented by a unary code, and a quantized DCT coefficient which is equal to a threshold is represented only by a “1” bit by ignoring a “0” bit.
When the coefficient absolute value abs or 220 is larger than 1, a “1” bit is assigned (230), or otherwise, a “0” bit is assigned (235). When the coefficient absolute value is larger than 1, a value obtained by subtracting 2 from the coefficient absolute value is updated as an absolute value abs (240). When the updated coefficient absolute value abs (hereinafter, this will be referred to as a coefficient absolute value) is 0, a “0” bit is assigned (250), or otherwise, a “1” bit is assigned (255). When the coefficient absolute value abs consists of “1” bits (260), a “0” bit is assigned if the coefficient absolute value is not larger than a threshold, or otherwise, exponential Golomb binarization is performed on a value (abs-s) obtained by subtracting the threshold from the coefficient absolute value.
In the entropy coding by using binarization using related art binary Golomb coding, a threshold S is fixed, and the coding depends on a compression data format. However, in a high bit rate environment, the fixed threshold is not appropriate.